package cool.qingqing;

/**
 * @author 高山青
 * @Date 2021/11/20  -   23:02
 */
public class BUB {
	public static void main(String[] args) {
		BUB bub = new BUB();
		int[] a = {3, 44, 38, 26, 2, 57, 89, 23};
		bub.bub(a);
	}

	public void bub(int[] a) {

		int length = a.length;
		boolean flag = true;
		while (flag){
			flag = false;

			for (int i = 0; i < length - 1; i++) {
				if (a[i] > a[i + 1]) {
					//交换
					int b = a[i];
					a[i] = a[i + 1];
					a[i + 1] = b;


					flag = true;
					System.out.println("交换了");
				} else {
					flag = true;
					System.out.println("没有交换");
				}


			}
			System.out.println("取出最大值");
			length--;
		}
		for (int i : a) {
			System.out.print(i + " | ");
		}

	}
}
